package cn.tedu.blogproject.exception;

import cn.tedu.blogproject.common.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler{
//
//        if(id < 0){
//        throw new IllegalArgumentException("参数不可小于0");
//    }
    @ExceptionHandler
    public JsonResult doHandlerIllegalArgumentException(IllegalArgumentException ex){
        log.error("ex: "  + ex.getMessage());
        return JsonResult.fail();
    }
}
